using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

/// <summary>
/// Summary description for FeedbackUtils
/// </summary>
public class FeedbackUtils
{
	public FeedbackUtils()
	{
	}

    public static void AddFeedback(feedback myFeedbackData)
    {
        StringBuilder myInsertQuery = new StringBuilder();
        String dbConn = ConfigurationManager.ConnectionStrings["WDPAConnectionString1"].ConnectionString;
        System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(dbConn);
        System.Data.SqlClient.SqlCommand sqlCommand = new System.Data.SqlClient.SqlCommand();

        myInsertQuery.Append("INSERT INTO [WDPA].[dbo].[Feedback]([Comment],[priority],[userID],[type],[URL],[date])   VALUES  ('");
        myInsertQuery.Append(myFeedbackData.FeedbackComment.ToString());
        myInsertQuery.Append("', ");
        myInsertQuery.Append(myFeedbackData.FeedbackPriorityID.ToString());
        myInsertQuery.Append(", '");
        myInsertQuery.Append(myFeedbackData.FeedbackUser.ToString());
        myInsertQuery.Append("', ");
        myInsertQuery.Append(myFeedbackData.FeedbackCatID.ToString());
        myInsertQuery.Append(", '");
        myInsertQuery.Append(myFeedbackData.FeedbackURL.ToString());
        myInsertQuery.Append("', getDate())");

        try
        {
            conn.Open();
            sqlCommand.Connection = conn;
            sqlCommand.CommandText = myInsertQuery.ToString();
            int rowsAffected = sqlCommand.ExecuteNonQuery();
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            if (conn != null)
            {
                conn.Close();
            }
        }

    }
}
